var util = {
		
		
	expExcel:function(action,beanName,keyArr,data){
		
		var form = $("#_tempExpForm");
		if(form.length != 0){
			form.remove();
		}
		
		form = $('<form id="_tempExpForm"></form>');
		// 设置属性
		form.attr('action', action);
		form.attr('method', 'post');
		form.attr('target', 'down_frame');
		
		for(var i = 0; i < keyArr.length; i++){
			
			var key = keyArr[i];
			
			// 创建Input
			var input = $('<input type="hidden" name="'+beanName+'.'+key+'" />');
			input.attr('value', data.field[key]);
			form.append(input);
		}
		
		// 提交表单--需要追加到body中否则无法提交
		//form.submit();
		form.appendTo(document.body).submit(); 
		
		
	},

	downloadFile : function(action,saveName,fileName) {
		
		
		var form = $("#_tempForm");
		if(form.length != 0){
			form.remove();
		}
		form = $('<form id="_tempForm"></form>');
		
		form.html("");
		// 设置属性
		form.attr('action', action);
		form.attr('method', 'post');
		// form的target属性决定form在哪个页面提交
		// _self -> 当前页面 _blank -> 新页面
		form.attr('target', 'down_frame');
		// 创建Input
		var saveNameInput = $('<input type="hidden" name="rmReqAttch.saveName" />');
		saveNameInput.attr('value', saveName);
		// 附加到Form
		form.append(saveNameInput);
		
		// 创建Input
		var fileNameInput = $('<input type="hidden" name="rmReqAttch.fileName" />');
		fileNameInput.attr('value', fileName);
		// 附加到Form
		form.append(fileNameInput);

		// 提交表单--需要追加到body中否则无法提交
		//form.submit();
		form.appendTo(document.body).submit(); 
		
		return false;

	},
	
	
	showDialog:function(retMsg, type, callBack){
		
		
		if(type == 2){
			layer.alert(retMsg, {title:['\u63d0\u793a\u4fe1\u606f',true],icon: 1},function(index){
				
				layer.close(index);
				
				if(callBack){
					var arr = callBack.split("=");
					eval(arr[1]);
				}
			});
		}else if(type == 1){
			layer.alert(retMsg, {title:['\u63d0\u793a\u4fe1\u606f',true],icon: 0},function(index){
				
				layer.close(index);
				
				if(callBack){
					var arr = callBack.split("=");
					eval(arr[1]);
				}
			});
		}else if(type == 0){
			layer.alert(retMsg, {title:['\u63d0\u793a\u4fe1\u606f',true],icon: 2},function(index){
				
				layer.close(index);
				
				if(callBack){
					var arr = callBack.split("=");
					eval(arr[1]);
				}
			});
		}else if(type == 3){
			
			
			layer.confirm(retMsg,{title:['\u63d0\u793a\u4fe1\u606f',true],yes:function(index){
				
				if(callBack){
					var arr = callBack.split("=");
					eval(arr[1]);
					layer.close(index);
				}
			}},function(index){
				layer.close(index);
				
			},function(index){
				layer.close(index);
			});
		}else if(type == 4){
			
			layer.alert(retMsg, {title:['\u63d0\u793a\u4fe1\u606f',true],icon: 2,cancel:function(index){
				
				if(callBack){
					var arr = callBack.split("=");
					eval(arr[1]);
				}
			}},function(index){
				
				layer.close(index);
				
				if(callBack){
					var arr = callBack.split("=");
					eval(arr[1]);
				}
			});
		}
		
		
	},
	
	
	//分页
	paging:function(data,pageNum,targetId,pageDivId,colNums){
		
		if(data.length == 0){
			
			$("#"+targetId).html("<tr><td colspan="+colNums+">未查询到数据！</td></tr>");
			$("#"+pageDivId).html("");
			return ;
		}
		//调用分页
		layui.laypage({
			cont: pageDivId,
			pages: Math.ceil(data.length / pageNum),
			skip: true,
			skin: '#066dc5',
			jump: function(obj) {
				
				$("#"+targetId).html(render(data,pageNum,obj.curr));
				// document.getElementById('content').innerHTML = render(obj.curr);
				
				//重新渲染复选框
				/**form.render('checkbox');
				form.on('checkbox(allselector)', function(data) {
					var elem = data.elem;

					$('#content').children('tr').each(function() {
						var $that = $(this);
						//全选或反选
						$that.children('td').eq(0).children('input[type=checkbox]')[0].checked = elem.checked;
						form.render('checkbox');
					});
				});

				//绑定所有编辑按钮事件						
				$('#content').children('tr').each(function() {
					var $that = $(this);
					$that.children('td:last-child').children('a[data-opt=edit]').on('click', function() {
						layer.msg($(this).data('name'));
					});

				});**/
				
				
				
				
			}
		});

	
	
	},
	
	openDivWin:function(url, title, w, h) {

		var winW = $(document).width();

		//var  winH = $(document).height();
		var winH = parent.$("#mainBody").height();
		if(winW < w) {
			w = winW - 30;
		}

		if(winH < h) {
			h = winH - 30;
		}

		var offSetX = (winW - w) / 2;
		var offSetY = (winH - h) / 2;

		if(title == null || title == '') {
			title = false;
		};
		if(url == null || url == '') {
			url = "404.html";
		};

		//w = 300;
		//h = 200;

		if(w == null || w == '') {
			w = 800;
		};
		if(h == null || h == '') {
			h = ($(window).height() - 50);
		};

		layer.open({
			type: 2,
			area: [w + 'px', h + 'px'],
			fix: false,
			maxmin: false,
			shade: 0.4,
			title: title,
			content: url,
			skin: 'layui-layer-rim',
			offset: [offSetY + 'px', offSetX + 'px'],
			move: false,
			closeBtn: 1
		});
	},
	
	 closeDivWin:function(){
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
	},
	
	getVal:function(str){
		if(str == null){
			return "";
		}else{
			
			return str;
		}
		
	},
	
	
	
	/**
	 * 调整弹出层高度
	 * 
	 */
	adjustDivHeight:function(height,id,adjustTitle,adjustTab){
		
		
		var winH = parent.parent.$("#mainBody").height();
	

		if(winH < height) {
			height = winH-55;
		}
		
		var contentHeight = height - adjustTitle -adjustTab;
	
		$("#"+id).css("position","fixed");
		$("#"+id).css("top",adjustTab);
		$("#"+id).css("width","100%");
		$("#"+id).css("height",contentHeight);
		$("#"+id).css("overflow","auto");
		
		
		 //style="position:fixed; top:42px;width:100%;height:400px;overflow:auto;"

		
	},
	
	//tab选项卡
	tabs:function(){
		
		$(".hd li").each(function(index,obj){
			
			//alert($(obj).attr("id"));
			
			$(obj).click(function(){
				
				$(".hd li").each(function(index,tabObj){
					$(tabObj).removeClass("on");
					$("#content-"+index).css("display","none");
						
				});
				
				$(this).addClass("on");
				var idArr = $(this).attr("id").split("-");
				$("#content-"+idArr[1]).css("display","block");
			});
			
			
			
		});
	}
	

}